import translations from './translations';
import store from "../../store";
import {GET_LANGUAGE} from "../../store/constants";

export default function customTranslate(template, replacements) {
	console.log("template 1" + template);
	replacements = replacements || {};
	let trans = translations[store.getters[GET_LANGUAGE]];
	// Translate
	template = (trans && trans[template]) || template;
	console.log("template 2" + template);
	// Replace
	return template.replace(/{([^}]+)}/g, function(_, key) {
		return (trans && trans[replacements[key]]) || replacements[key] || '{' + key + '}';
	});
}
